package com.powervision.mvvmdemo.ui.viewmodel

import com.powervision.base.base.BaseViewModel
import com.powervision.base.util.LogUtils
import com.powervision.http.observer.StateLiveData
import com.powervision.mvvmdemo.ui.model.ProjectListModel
import com.powervision.mvvmdemo.ui.repository.ProjectListRepository

/**
 * @auth: njb
 * @date: 2021/12/20 11:42
 * @desc: 描述
 */
class ProjectListViewModel : BaseViewModel() {
    private val mProjectListRepository by lazy { ProjectListRepository() }

    val mProjectListLiveData = StateLiveData<ProjectListModel>()

    fun projectList(page: Int, cid: Int) {
        launchWithLoading(requestBlock = {
            mProjectListRepository.projectList(page, cid)
        }, resultCallback = {
            mProjectListLiveData.value = it
            LogUtils.d("--projectlist--", it.data.toString())
        })
    }
}